#!/usr/bin/env bash
# ******************************************************
# Filename     :
# Last modified:	2024-05-06 13:21
# Version      :
# Author       : jack.zang
# Email        : jack.zang@aishangwei.net
# Description  : for centos 7
# 使用方法：source <(curl -sL https://gitee.com/jack_zang/public-scripts/raw/master/shell/java/jdk_install.sh)
# ******************************************************

read -t 20 -p "请输入要安装的 Oracle Java JDK 版本，例：8u202 17 21 22 ,直接回车安装默认版本 17：" JDKV

[ -z "$JDKV" ] && JDKV=17

if [ $JDKV -lt 17 ];then
  URL="https://files.aishangwei.net/files/jdk/jdk-${JDKV}-linux-x64.rpm"
else
  URL="https://download.oracle.com/java/${JDKV}/latest/jdk-${JDKV}_linux-x64_bin.rpm"
fi

curl -Lo /tmp/jdk-${JDKV}_linux-x64_bin.rpm https://download.oracle.com/java/${JDKV}/latest/jdk-${JDKV}_linux-x64_bin.rpm
yum -y localinstall /tmp/jdk-${JDKV}_linux-x64_bin.rpm
rm -f /tmp/jdk-${JDKV}_linux-x64_bin.rpm

echo "安装的 JDK 版本为："
java -version



















